package com.runfast.waimai.web.controller.Driver_controller;


import com.runfast.paotui.dao.model.RunfastLoginRecord;
import com.runfast.paotui.dao.model.RunfastShopper;
import com.runfast.waimai.service.RunfastGoodsSellRecordService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("/driver/commission/*")
public class DriverCommissionController extends DriverBaseController {
	/**
	 * 骑手收入统计
	 * **/
	@Resource
	private RunfastGoodsSellRecordService goodsSellRecordService;


	@RequestMapping(value="monlist",method=RequestMethod.POST)////验证
	public @ResponseBody ModelMap monlist( String  createTime, String  createTime1,String token) throws ParseException {
		//		//收入统计creartime entTime 骑手id
		ModelMap model = new ModelMap();
		RunfastShopper shopper  = super.getLoginShopper(token);

		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		Date date=dateFormat.parse(createTime);
		Date date1=dateFormat.parse(createTime1);
		if(shopper!=null){
			//createTime为起始时间，还有一个createTime1为结束时间,查询的是goodsSellRecord集合
			model.put("rows",goodsSellRecordService.findBymonth(shopper.getId(),date,date1));
			model.put("sucess",true);
		
		}else {model.put("msg","输入的条件有误");
		model.put("sucess",false);}

		return model;
		}
}
